﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SqlSugar_Geometry_Model
{
    public class Polygon
    {
        /// <summary>
        /// 面的组成位置点集合
        /// </summary>
        public Location[] polygon { get; set; }

        /// <summary>
        /// 面对象
        /// </summary>
        /// <param name="locations">位置点集合</param>
        public Polygon(Location[] locations)
        {
            polygon = locations;
        }

        /// <summary>
        /// 重新ToString()
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            string linestr = "";
            for (int i = 0; i < polygon.Count(); i++)
            {
                linestr += polygon[i].X + " " + polygon[i].Y + " " + polygon[i].Z + ",";
            }
            linestr = linestr.Substring(0, linestr.Length - 1);     //linestr.Length-1是去掉最后一个"，"
            return $"POLYGON ((" + linestr + "))";
        }
    }
}